<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- meta tags, link to css:  -->
	<%@ include file="./jsp-includes/mymetaheader.jsp" %>
	
	<!--  Ajax-Includes -->
    <script type='text/javascript' src='/GroupMe/dwr/interface/DWRGroupManager.js'></script>
    <script type='text/javascript' src='/GroupMe/dwr/engine.js'></script>
    <script type='text/javascript' src='/GroupMe/dwr/util.js'></script>
	<script src="<%= request.getContextPath()%>/scriptaculous/prototype.js" type="text/javascript"></script>
	
	<title>GroupMe! - The Social Semantic Web [Add Resource manually]</title>
	
	<script type="text/javascript" language="javascript"><!--
		function previewResource(){
			var url = dwr.util.getValue("urlinput");
			if(url.substr(0, 7) != "http://") {
				url = "http://" + url;
			}
			$('resource_preview').src = url;
			parent.frames[resource_preview].window.location.reload();
		}

		function addResourceToGroup() {
			var description = dwr.util.getValue("descriptioninput").replace(/\n/g,"<br>");
		    var	titel = dwr.util.getValue("titelinput");
			var	urlinput = dwr.util.getValue("urlinput");
			hs.closeAll();
	   		DWRResourceAggregation.addResourceManual(urlinput, titel, description, loadResourceIntoGroup);
	   	}
	   	//-->
	</script>
</head>
<body onload="">
	<!-- title image, logo:  -->
	<div id="groupme_smallresource_header">
		<img height="40px" src="<%= request.getContextPath() %>/images/groupme-logo-small.png" alt="Semantic Web"/>
	</div>
	
	<!-- Menu: -->
	<div id="small_menu">
	</div>
	<!-- content and sidebar -->
	<c:choose>
		<c:when test="${userManager.loggedIn && groupManager.groupID!=null}">
		<!-- Content: -->
		<div id="manual_add_content" style="text-align: center">
			<iframe id="resource_preview" style="width:450px; height: 330px; margin-top: 30px" src="">
			</iframe>
			<br/>
			<form action="javascript:addResourceToGroup()" name="manualAdd">
				<strong>Add a Resource manually:</strong><br/>
				<div style="width:450px">
					<div style="position: relative; margin: 5px; width: 120px; height: 30px; text-align:right; float:left">
						URL:
					</div>
					<div style="position: relative; margin: 5px; width: 250px; height: 30px; text-align:right; float:left">
						<input type="text" id="urlinput" size="37" maxlength="255"/>
					</div>
					<div style="position: relative; margin: 5px; width: 50px; height: 30px; text-align:left; float: left;">
						<input id="previewResource()" type="button" value="preview" onclick="previewResource()"/>
					</div>
					<div style="position: relative; margin: 5px; width: 120px; height: 30px; text-align:right; float:left">
						Titel:
					</div>
					<div style="position: relative; margin: 5px; width: 250px; height: 30px; text-align:right; float:left">
						<input type="text" id="titelinput" size="37" maxlength="255"/>
					</div>
					<div style="position: relative; margin: 5px; width: 50px; height: 30px; text-align:left; float:left">
					</div>
					<div style="position: relative; margin: 5px; width: 120px; height: 60px; text-align:right; float:left">
						Description:
					</div>
					<div style="position: relative; margin: 5px; width: 250px; height: 60px; text-align:right; float:left">
						<textarea cols="28" rows="2" id="descriptioninput"></textarea>
					</div>
					<div style="position: relative; margin: 5px; width: 50px; height: 60px; text-align:left; float:left">
					</div>
					<div style="position: relative; margin: 5px; width: 120px; height: 60px; text-align:right; float:left">
					</div>
					<div style="position: relative; margin: 5px; width: 250px; height: 60px; text-align:right; float:left">
						<input id="addManualButton" type="submit" value="add to current group"/>
					</div>
					<div style="position: relative; margin: 5px; width: 50px; height: 60px; text-align:left; float:left">
					</div>
				</div>
			</form>
		</div>
		</c:when>
		<c:otherwise>
			<script language="javascript"> 
				window.location='<%= request.getContextPath() %>/groupme_home.jsp'; 
			</script>
		</c:otherwise>
	</c:choose>
	<div id="footer" style="font-size:0.5em">
		<%@ include file="./jsp-includes/footer.jsp" %>
	</div>
</body>
</html>